package com.flyox.game.militarychess.message;

import java.io.Serializable;

import com.flyox.game.militarychess.util.SerialUtil;
/**
 * 所有包的组装方式
 * @author sunwei
 */
public class ChessPackage implements Serializable{

	private static final long serialVersionUID = -6978063903450618491L;
	private int cmd=0;//命令类型
	private String playerID;//用户id
	private byte[] content;//内容 加密并序列化后的 request
	
	public ChessPackage(int cmd){
		this.cmd=cmd;
	}
	public ChessPackage(int cmd,String playerID){
		this.cmd=cmd;
		this.playerID=playerID;
	}
	public ChessPackage(int cmd,String playerID,byte[] content){
		this.cmd=cmd;
		this.playerID=playerID;
		this.content=content;
	}
	
	public ChessPackage(byte[] msg) throws Exception{
		Serializable s=SerialUtil.deSerial(msg);
		ChessPackage rm=(ChessPackage)s;
		this.cmd=rm.getCmd();
		this.content=rm.getContent();
	}
	
	public int getCmd() {
		return cmd;
	}
	public void setCmd(int cmd) {
		this.cmd = cmd;
	}
	public byte[] getContent() {
		return content;
	}
	public void setContent(byte[] content) {
		this.content = content;
	}
	public String getPlayerID() {
		return playerID;
	}
	public void setPlayerID(String playerID) {
		this.playerID = playerID;
	}
	
}
